<?php
	include_once "Client.php";
	include 'restritoCliente.php';

	//$_SESSION['Usuario'] >>Tem todas as informações de usuario necessarias... 
	header("Content-Type: text/html; charset=utf-8", true);
?>

<!DOCTYPE html>
<html>
	<head>
		<title>Minha Tela</title>
		<script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="css/style.css">
	</head>
	<body>
		<div class="container">
			<div class="head">
				<a id="logo" href="index.php">CKJ Store</a>
				
				<?php 
					include 'head_login.php';
				?>
			</div>

			<!-- fim do header-->

			<?php include 'head_search.php'; ?>

			<?php 
				if(isset($_GET['request_budget_success'])){
				    if($_GET['request_budget_success'] == 'true'){
				         echo '<span class="flash-message">Orçamento Solicitado com Sucesso</span>';
				    }
				}   
			?>

			<div><span class="highlights">Minha Tela</span></div>

			<div id="info" class="border">
				<?php     
					if (!isset($_SESSION)){
						session_start();
					}
					$cliente = $_SESSION['Usuario'];
					
					echo "<span class=\"info-line name\">".$cliente->Name."</span>";
					echo "<a href='EditarCliente.php?idc=$cliente->CPF'>Alterar cadastro</a>";
					echo "<span class=\"info-line\">".$cliente->Street.", ". $cliente->Complement."</span>";
					echo "<span class=\"info-line\">".$cliente->District.", ".$cliente->City."-".$cliente->State."</span>"
				?>
			</div>

			<div id="activities">
				<a href="MeuCarrinho.php" class="title-activity border">Carrinho</a>

				<a href="#" class="title-activity border budget-activity">Orçamentos</a>
				<ul id="budget" class="activity-list"></ul>

				<a href="#" class="title-activity border request-activity">Pedidos</a>
				<ul id="request" class="activity-list"></ul>
			</div>

			<script type="text/javascript">

				$(".budget-activity").toggle(function (e) {
					var itens = [
						<?php include "acaoMeusOrcamentosCliente.php"; ?>
					]

					if (itens.length > 0) {
						for (var i = 0; i <= itens.length; i++) {
							var item = $(itens[i]);
							item.hide();
							item.appendTo($("#budget")).slideDown("slow");
						};
					}
					else{
						var item = $('<li class="item-activity border">' +
										'<a class="link-activity">' +
											'<span class="main-item">Não existem orçamentos</span>' +
										'</a>' +
									'</li>');
						item.hide();
						item.appendTo($("#budget")).slideDown("slow");
					};

					e.preventDefault();
				},

				// Função quando o numero do clique é par
				function (e) {
				 	$("#budget").find($(".item-activity")).slideUp("slow", function () {
				 		$(this).remove();
				 	}) 

				 	e.preventDefault();
				});

				$(".request-activity").toggle(function (e) {
					var itens = [
						<?php include "acaoMeusPedidosCliente.php"; ?>
					]

					if (itens.length > 0){
						for (var i = 0; i <= itens.length; i++) {
							var item = $(itens[i]);
							item.hide();
							item.appendTo($("#request")).slideDown("slow");
						};
					}else{
						var item = $('<li class="item-activity border">' +
										'<a class="link-activity">' +
											'<span class="main-item">Não existem pedidos</span>' +
										'</a>' +
									'</li>');
						item.hide();
						item.appendTo($("#request")).slideDown("slow");
					};

					e.preventDefault();
				},

				// Função quando o numero do clique é par
				function (e) {
				 	$("#request").find($(".item-activity")).slideUp("slow", function () {
				 		$(this).remove();
				 	}) 

				 	e.preventDefault();
				});
					
			</script>

		</div>
	</body>
</html>